/* ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
   Module Name          : com.yaodian100.crm.cs.web.ContactWindowAction
   Module Description   :

   Date Created      : 2010/1/27
   Original Author   : andy.chuang
   Team              : yaodian100
   ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
   MODIFICATION HISTORY
   ------------------------------------------------------------------------------
   Date Modified       Modified by       Comments
   ------------------------------------------------------------------------------
   ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
package com.yaodian100.crm.cs.web;

import java.util.Date;

import javax.annotation.Resource;

import com.yaodian100.core.admin.utils.AdminHelper;
import com.yaodian100.core.common.service.BaseManager;
import com.yaodian100.crm.cs.entity.GroupContactWindow;

/**
 * @author andy.chuang
 *
 */
public class ContactWindowAction {
    private String iamlazy;
    private String name;
    private String groupId;
    private String holidayId;
    private String to;
    private String cc;
    private String AJAX;
    @Resource
    private BaseManager baseMgr;
    public String page(){
	if(AJAX!=null && AJAX.equals("true")){
	    return iamlazy+"_ajax";
	}else{
	    return iamlazy;
	}
    }
    public String update(){
	GroupContactWindow gcw=(GroupContactWindow)baseMgr.get(GroupContactWindow.class, groupId);
	Date date=new Date();
	if(gcw!=null){
	    gcw.setCcMail(cc);
		gcw.setHolidayId(holidayId);
		gcw.setModifyUser(AdminHelper.getUserDetails().getUsername());
		gcw.setName(name);
		gcw.setToMail(to);
		baseMgr.update(gcw);
	}else{
	    gcw=new GroupContactWindow();
	    gcw.setGroupId(groupId);
	    gcw.setCreateDate(date);
	    gcw.setCreateUser(AdminHelper.getUserDetails().getUsername());
	    gcw.setCcMail(cc);
		gcw.setHolidayId(holidayId);
		gcw.setModifyUser(AdminHelper.getUserDetails().getUsername());
		gcw.setName(name);
		gcw.setToMail(to);
		baseMgr.save(gcw);
	}
	
	
	
	return "updateContactWindow";
    }
    public String delete(){
	    GroupContactWindow gcw=(GroupContactWindow)baseMgr.get(GroupContactWindow.class, groupId);
	    baseMgr.delete(gcw);

	return "list";
    }
    /**
     * @return the iamlazy
     */
    public String getIamlazy() {
        return iamlazy;
    }
    /**
     * @param iamlazy the iamlazy to set
     */
    public void setIamlazy(String iamlazy) {
        this.iamlazy = iamlazy;
    }

    /**
     * @return the name
     */
    public String getName() {
        return name;
    }
    /**
     * @param name the name to set
     */
    public void setName(String name) {
        this.name = name;
    }
    /**
     * @return the groupId
     */
    public String getGroupId() {
        return groupId;
    }
    /**
     * @param groupId the groupId to set
     */
    public void setGroupId(String groupId) {
        this.groupId = groupId;
    }
    /**
     * @return the holidayId
     */
    public String getHolidayId() {
        return holidayId;
    }
    /**
     * @param holidayId the holidayId to set
     */
    public void setHolidayId(String holidayId) {
        this.holidayId = holidayId;
    }
    /**
     * @return the to
     */
    public String getTo() {
        return to;
    }
    /**
     * @param to the to to set
     */
    public void setTo(String to) {
        this.to = to;
    }
    /**
     * @return the cc
     */
    public String getCc() {
        return cc;
    }
    /**
     * @param cc the cc to set
     */
    public void setCc(String cc) {
        this.cc = cc;
    }
    /**
     * @return the aJAX
     */
    public String getAJAX() {
        return AJAX;
    }
    /**
     * @param aJAX the aJAX to set
     */
    public void setAJAX(String aJAX) {
        AJAX = aJAX;
    }
}
